package newx.com.control.lite
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	import newx.BaseObject;
	
	public class NxButtonLite extends BaseObject
	{
		private var _up			:uint	=	1;
		private var _down			:uint	=	1;
		private var _rollover		:uint	=	1;
		
		private var _onClick		:uint	=	1;
		private var _onRollOver	:uint	=	1;
		private var _onRollOut		:uint	=	1;
		
		private var _clip			:MovieClip;
		
		public function NxButtonLite()
		{
			super(null);
		}
		
		public static function CreatButton(
			buttonClip	:MovieClip,
			up			:uint,
			down		:uint,
			rollover	:uint):void
		{
			buttonClip.gotoAndStop(up);
			
			buttonClip.buttonMode		=	true;
			
			buttonClip.onDownHande		=	function (e:MouseEvent):void
			{
				buttonClip.gotoAndStop(down);
			}
				
			buttonClip.onRollOutHande	=	function (e:MouseEvent):void
			{
				buttonClip.gotoAndStop(up);
			}
			
			buttonClip.onRollOverHande	=	function (e:MouseEvent):void
			{
				buttonClip.gotoAndStop(rollover);
			}
			
			buttonClip.addEventListener(MouseEvent.MOUSE_DOWN	,buttonClip.onDownHande);
			buttonClip.addEventListener(MouseEvent.ROLL_OUT		,buttonClip.onRollOutHande);
			buttonClip.addEventListener(MouseEvent.ROLL_OVER	,buttonClip.onRollOverHande);
		}
		
		public static function DestroyButton(buttonClip:MovieClip):void
		{
			if(buttonClip == null || buttonClip.onDownHande == null)
			{
				return;
			}
			buttonClip.removeEventListener(MouseEvent.MOUSE_DOWN	,buttonClip.onDownHande);
			buttonClip.removeEventListener(MouseEvent.ROLL_OUT		,buttonClip.onRollOutHande);
			buttonClip.removeEventListener(MouseEvent.ROLL_OVER		,buttonClip.onRollOverHande);
			
			buttonClip.onDownHande		=	null;			
			buttonClip.onRollOutHande	=	null;			
			buttonClip.onRollOverHande	=	null;
			
			buttonClip.buttonMode		=	false;
			
//			GC.gc();
		}
	}
}